package com.edu.app.mapper.linkmappers;

import com.edu.app.bean.core.SysWxUser;
import com.edu.app.bean.linkbeans.SysUserWxUserBind;
import com.edu.app.util.AppBaseMapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface SysUserWxUserBindMapper extends AppBaseMapper<SysUserWxUserBind> {
    @Select("SELECT t3.* FROM S_USER t1 INNER JOIN S_USER_WXUSER t2 on t1.ID = t2.USER_ID INNER " +
            "JOIN S_WXUSER t3 on t2.WXUSER_ID = t3.ID " +
            "WHERE t1.id = #{id};")
    List<SysWxUser> getWxUserListByUserId(Integer id);

    @Select("SELECT t1.* FROM  S_USER_WXUSER t1  INNER JOIN S_WXUSER t2 on t1.USER_ID = t2.ID " +
            "WHERE t2.openid = #{openid} ")
    SysUserWxUserBind getUserWxUserBindByOpendId(String openid);


    //注：传参数到Mapper层，当参数超过两个以上的时候，注意使用@Param标注
    @Select("SELECT * FROM S_USER_WXUSER WHERE user_id = #{user_id} and wxuser_id = #{wxuser_id}")
    SysUserWxUserBind getUserWxUser(@Param("user_id") Integer user_id, @Param("wxuser_id") Integer wxuser_id);

    @Select("DELETE FROM S_USER_WXUSER WHERE user_id = #{user_id}")
    Integer deleteUserWxUserBindByUserId(Integer user_id);

    @Select("DELETE FROM S_USER_WXUSER WHERE wxuser_id = #{wxuser_id}")
    Integer deleteUserWxUserBindByWxUserId(Integer wxuser_id);
}
